package com.lb.activity.mapper;

import com.lb.activity.po.User;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

public interface UserMapper extends Mapper<User> {

    /**
     * 用户名登录
     * @param userName
     * @return
     */
    @Select("SELECT u.* FROM user u WHERE u.user_name = #{userName} and u.status = 0")
    User getUserByUserName(@Param("userName") String userName);

    @Select("select u.* from user u where u.is_leader = 1 and u.group_id = #{groupId} ")
    User getUserByDeptId(@Param("groupId")Long groupId);

    @Select("SELECT u.id FROM user u WHERE u.group_id = #{groupId} and u.status = 0")
    List<Long> selectUsersByGroupId(Long groupId);

    @Select(" SELECT  id, user_name, password,\n" +
            "      group_id, status, create_time,\n" +
            "      update_time FROM user WHERE user_name = #{username} AND STATUS = 0")
    User selectByUserLoginName(String uname);
}
